/**
 * Created by c on 2017-11-17.
 */

//加载审核信息
function chstate(state){
    var $str;
    if(state==0){
        $str='<span style="color: cornflowerblue">待审核</span>';
    } else if(state==1){
        $str='<span style="color: green">已通过</span>';
    } else if(state==2){
        $str='<span style="color: red">未通过</span>';
    }
    return $str;
}
//加载操作信息
function caozuo(e,value,row){
    var $str ;
    $str = '<button type="button" class="layui-btn layui-btn-mini showDetail" >查看</button>';
    if(value.planChstate==2){
        $str += '<button class="layui-btn layui-btn-normal layui-btn-mini updatePur">编辑</button>';
    }
    return $str;
}

window.optEvents= {
    "click .showDetail": function (e,value,row) {
       location.href = ctx+"/pur/searchOne?planNum="+row.planNum;
    },
    "click .updatePur":function(e,value,row){
        purEdit(row);
    }
}

function purEdit(row){
    location.href=ctx+"/pur/purEdit?planNum="+row.planNum;
};

//搜索日期插件
$(function () {
    laydate.render({
        elem:'[name=startDate]'
    })
    laydate.render({
        elem:'[name=endDate]'
    })
});

//模糊查询
function search(){
    var param={};
    param.planNum=$("input[name='planNum']").val();
    param.planChstate=$("select[name='planChstate']").val();
    param.startDate=$("input[name='startDate']").val();
    param.endDate=$("input[name='endDate']").val();
    $("#purTable").bootstrapTable("refresh",{query:param});
}

$(function(){
    //设置table背景颜色
    $("table#delTable").children().find(".back").css({"background-color":"#838383","color":"white"})
})
